package org.helsoft.mojo.api;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

public abstract class AbstractLoggerMojo extends AbstractMojo {

	protected final void fail(String message, Throwable t) throws MojoExecutionException {
		throw new MojoExecutionException(message, t);
	}

	protected final void fail(String message) throws MojoExecutionException {
		throw new MojoExecutionException(message);
	}

	protected final void fail(Throwable t) throws MojoExecutionException {
		throw new MojoExecutionException(t.getMessage(), t);
	}
	
	protected void info(String format, Object ...args) {
		getLog().info(args.length == 0 ? format : String.format(format, args));
	}
	
	protected void info(Throwable t) {
		getLog().info(t);
	}

	protected void info(CharSequence message, Throwable t) {
		getLog().info(message, t);
	}
	
	protected void error(String format, Object ...args) {
		getLog().error(args.length == 0 ? format : String.format(format, args));
	}
	
	protected void error(Throwable t) {
		getLog().error(t);
	}

	protected void error(CharSequence message, Throwable t) {
		getLog().error(message, t);
	}
	
	protected void warn(String format, Object ...args) {
		getLog().warn(args.length == 0 ? format : String.format(format, args));
	}
	
	protected void warn(Throwable t) {
		getLog().warn(t);
	}

	protected void warn(CharSequence message, Throwable t) {
		getLog().warn(message, t);
	}
	
	protected void debug(String format, Object ...args) {
		getLog().debug(args.length == 0 ? format : String.format(format, args));
	}
	
	protected void debug(Throwable t) {
		getLog().debug(t);
	}

	protected void debug(CharSequence message, Throwable t) {
		getLog().debug(message, t);
	}
	
}
